package cn.myworld.algorithm.common;

/**
 * 排序父类
 */
public class BaseSort {

    // 比较元素a是否大于元素b
    public static boolean greater(Comparable a, Comparable b) {
        return a.compareTo(b) > 0;
    }

    // 比较元素a是否小于元素b
    public static boolean less(Comparable a, Comparable b) {
        return a.compareTo(b) < 0;
    }

    // 数组元素i和j交换位置
    public static void exch(Comparable[] a, int i, int j) {
        Comparable t = a[i];
        a[i] = a[j];
        a[j] = t;
    }

}
